﻿<%@ Page Language="c#" ContentType="text/html" ResponseEncoding="utf-8" Async="true" MasterPageFile="~/administration/master_popup.master" Inherits="ACM.cmsarea08.Administration.Core.OptPageBase" %>
<%@ MasterType VirtualPath="~/administration/master_popup.master" %>



<asp:Content ID="PageBody" Runat="server" ContentPlaceHolderID="MasterBody">
<div id="option_popup">
<div class="popup_msgs">
<% Response.Write(rm.GetString("insert_module")); %>
</div>
<div class="popup_input">
<asp:DropDownList ID="droptemplate" runat="server"></asp:DropDownList>
</div>gasrgasrgawr
<div class="popup_btms">
<asp:Button id="confirm_choose" runat="server" text=""  ></asp:Button>
<input type="hidden" id="newvalue" runat="server"  />
</div>
</div>
<script language="c#" runat="server">
private string id = "";
private string templateid = "";
private  System.Data.DataSet ds=null;
private ACM.cmsarea08.Administration.Core.DBClass dclass = new ACM.cmsarea08.Administration.Core.DBClass();
protected override void OnInit(EventArgs e){
	base.OnInit(e);
	confirm_choose.Click += new EventHandler(SalvaTemplateId);
id = Request.QueryString["findid"].ToString();

string query = "select id,titolo,(select template_id from {0}menu_elemento where id='{1}') as miotemplate from {0}template ;";
ds = dclass.ExecuteDataset(string.Format(query,ACM.cmsarea08.mainconfiguration.MainConf.PrefissoTabelle,Request.QueryString["findid"].ToString()));
templateid = ds.Tables[0].Rows[0]["miotemplate"].ToString();
//Response.Write(string.Format(query,ACM.cmsarea08.mainconfiguration.MainConf.PrefissoTabelle,Request.QueryString["findid"].ToString()));

}

private void Page_Load(Object o, EventArgs e){
Response.Write(templateid + "<hr>");
	if(!Page.IsPostBack){
		confirm_choose.Text=rm.GetString("next_button");
		if(ds==null){
			
			return;
		}
		droptemplate.Items.Clear();		
		droptemplate.DataTextField = "titolo";
		droptemplate.DataValueField = "id";
		droptemplate.DataSource = ds;
		droptemplate.DataBind();
		droptemplate.Items.Insert(0,new ListItem("---","-1"));
		droptemplate.SelectedValue = templateid;
	

		
	}
}
private void SalvaTemplateId(object o, EventArgs e){
	int reso = 0;
	reso = dclass.ExecuteScalar("update " + ACM.cmsarea08.mainconfiguration.MainConf.PrefissoTabelle + "menu_elemento set template_id='" + templateid + "' where" +
								" id='" + id + "' ;");
	if(reso>0)
		Response.Write("<script language=\"javascript\">top.SmoothBoxGoToUrl(\"../core/gesmenuitem.aspx\")  ; "+((char)60)+"/script>");						


}
</script>




</asp:content>